package com.wwtech.epp.ui.activity.friend;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.wwtech.epp.R;
import com.wwtech.epp.application.AppConfig;
import com.wwtech.epp.base.BaseActivity;
import com.wwtech.epp.ui.activity.friend.component.DaggerAddGroupComponent;
import com.wwtech.epp.ui.activity.friend.contract.AddGroupContract;
import com.wwtech.epp.ui.activity.friend.module.AddGroupModule;
import com.wwtech.epp.ui.activity.friend.presenter.AddGroupPresenter;
import com.wwtech.epp.ui.adapter.main.ContactAdapter;
import com.wwtech.epp.ui.adapter.main.ContactAddFriendAdapter;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author hzp
 * @Package com.wwtech.epp.ui.activity.friend
 * @Description: $description
 * @date 2017/09/12 13:04:59
 */

public class AddGroupActivity extends BaseActivity implements AddGroupContract.View {

    @Inject
    AddGroupPresenter mPresenter;

    @Inject
    ContactAdapter contactAdapter;
    @Inject
    ContactAddFriendAdapter contactAddFriendAdapter;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        setContentView(R.layout.activity_add_group);
        ButterKnife.bind(this);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    protected void initData() {
        setTitle(getIntent().getStringExtra("title"));
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        if(getIntent().getStringExtra("title").equals("发起聊天")) {
            recyclerView.setAdapter(contactAdapter);
        } else {
            recyclerView.setAdapter(contactAddFriendAdapter);
        }
    }

    @Override
    protected void setupActivityComponent() {
        DaggerAddGroupComponent
                .builder()
                .appComponent(((AppConfig) getApplication()).getApplicationComponent())
                .addGroupModule(new AddGroupModule(this))
                .build()
                .inject(this);
    }

    @Override
    public void setPresenter(AddGroupContract.AddGroupContractPresenter presenter) {
        mPresenter = (AddGroupPresenter) presenter;
    }

    @Override
    public void showProgressDialog() {
        progressDialog.show();
    }

    @Override
    public void closeProgressDialog() {
        progressDialog.hide();
    }

}